package com.cadre.web.controller.officer;

import com.cadre.common.utils.R;
import com.cadre.common.utils.common.GenerateUUID;
import com.cadre.common.utils.oldutil.ValidatorUtils;
import com.cadre.system.domain.officer.PX_PXBXX_DETAIL;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.cadre.system.service.PX_PXBXX_DETAILService;


import javax.annotation.Resource;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(tags = {"培训详情接口"})
@RequestMapping({"/profess/PX_PXBXX_DETAIL"})
@RestController
/* loaded from: PX_PXBXX_DETAILController.class */
public class PX_PXBXX_DETAILController {
    @Resource
    private PX_PXBXX_DETAILService PX_PXBXX_DETAILService;

    @GetMapping({"/selectByAll"})
    @ApiOperation("获取信息")
    public R selectByAll(PX_PXBXX_DETAIL px_PXBXX_DETAIL) {
        Map<String, Object> map = new HashMap<>();
        map.put("pxbcode", px_PXBXX_DETAIL.getPxbcode());
        return R.ok().put("data", (Object) this.PX_PXBXX_DETAILService.selectByAll(map));
    }

    @GetMapping({"/info/{flowId}"})
    @ApiOperation("获取信息")
    public R info(@PathVariable("flowId") String flowId) {
        return R.ok().put("data", (Object) ((PX_PXBXX_DETAIL) this.PX_PXBXX_DETAILService.getById(flowId)));
    }

    @PostMapping({"/save"})
    @ApiOperation("添")
    public R save(@RequestBody PX_PXBXX_DETAIL PX_PXBXX_DETAIL) {
        PX_PXBXX_DETAIL.setPxbcode(GenerateUUID.getUUID());
        this.PX_PXBXX_DETAILService.save(PX_PXBXX_DETAIL);
        return R.ok();
    }

    @PostMapping({"/update"})
    @ApiOperation("改")
    public R update(@RequestBody PX_PXBXX_DETAIL PX_PXBXX_DETAIL) {
        ValidatorUtils.validateEntity(PX_PXBXX_DETAIL, new Class[0]);
        this.PX_PXBXX_DETAILService.updateById(PX_PXBXX_DETAIL);
        return R.ok();
    }

    @PostMapping({"/saveList"})
    @ApiOperation("批量添")
    public R saveList(@RequestBody List<PX_PXBXX_DETAIL> PX_PXBXX_DETAILs) {
        if (PX_PXBXX_DETAILs.size() > 0) {
            for (int i = 0; i < PX_PXBXX_DETAILs.size(); i++) {
                new PX_PXBXX_DETAIL().setFlowid(GenerateUUID.getUUID());
                this.PX_PXBXX_DETAILService.save(PX_PXBXX_DETAILs.get(i));
            }
        }
        return R.ok();
    }

    @PostMapping({"/updateList"})
    @ApiOperation("批量改")
    public R updateList(@RequestBody List<PX_PXBXX_DETAIL> entityList) {
        this.PX_PXBXX_DETAILService.updateBatchById(entityList);
        return R.ok();
    }

    @PostMapping({"/delete"})
    @ApiOperation("删")
    public R delete(@RequestBody String[] flowIds) {
        this.PX_PXBXX_DETAILService.removeBatchByIds(Arrays.asList(flowIds));
        return R.ok();
    }
}
